package cn.wingware.util;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.WebApplicationContext;

public class SpringUtils {

	private static SpringUtils springUtils = new SpringUtils();

	private ApplicationContext applicationContext;

	private SpringUtils() {
		/*
		 * 初始化进入
		 */
	}

	/**
	 * 
	 * <p>
	 * Description:获得实例
	 * </p>
	 * 
	 * @return
	 * @author ZhangXiang
	 * @date 2011-4-20
	 */
	public static SpringUtils newInstants() {
		return springUtils;
	}

	/**
	 * 
	 * <p>
	 * Description:初始化
	 * </p>
	 * 
	 * @author ZhangXiang
	 * @date 2011-4-20
	 */
	public void init(WebApplicationContext webApplicationContext) {
		setWebApplicationContext(webApplicationContext);
	}

	public void setWebApplicationContext(ApplicationContext applicationContext) {
		this.applicationContext = applicationContext;
	}

	public Object getBean(String name) {
		return applicationContext.getBean(name);
	}
}
